<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <title>入口页</title>
    <link rel="stylesheet" href="../../css/reset.css">
    <style>
        body,
        img {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }

        #dialogIndex {
            width: 100%;
            height: 100%;
            background-size: 100% 100%;
        }
    </style>
</head>

<body>
    <div id="dialogIndex">
    </div>
</body>
<script src="./script/autosize.js"></script>
<script src="./script/jquery_three_two_one.js"></script>
<script src="./script/fastclick.js"></script>
<script src="./script/app.js"></script>
<script>
    apiready = function () {
        var app = new APP();
        //调用原生导航栏
        function openNavTabWin() {
            var param = {
                name: 'nav-tab',
                title: 'nav-tab',
                bgColor: '#fff',
                slidBackEnabled: false,
                tabBar: {
                    animated: false,
                    scrollEnabled: false,
                    list: [
                        {
                            "text": "首页",
                            "iconPath": "widget://image/iconhomeone.png",
                            "selectedIconPath": "widget://image/iconhometwo.png"
                        },
                        {
                            "text": "市场",
                            "iconPath": "widget://image/iconshichangone.png",
                            "selectedIconPath": "widget://image/iconshichangtwo.png"
                        },
                        {
                            "text": "发现",
                            "iconPath": "widget://image/iconnewsone.png",
                            "selectedIconPath": "widget://image/iconnewstwo.png"
                        },
                        {
                            "text": "我的",
                            "iconPath": "widget://image/iconmeone.png",
                            "selectedIconPath": "widget://image/iconmetwo.png"
                        }
                    ],
                    frames: [
                        {
                            "title": "首页",
                            "name": "firstPage",
                            "url": "widget://html/mainpage/indexpage.html"
                        },
                        {
                            "title": "市场",
                            "name": "orginPage",
                            "url": "widget://html/mainpage/neworin.html"
                        },
                        {
                            "title": "发现",
                            "name": "newFlash",
                            "url": "widget://html/mainpage/newflash.html"
                        },
                        {
                            "title": "我的",
                            "name": "newFlash",
                            "url": "widget://html/mainpage/minepage.html"
                        }
                    ]
                }
            }
            api.openTabLayout(param);
        }
        //打开手势密码
        function openHandPassWord(params) {
            var accountSet = app.getAccountSet();
            var lineColor = "#ffcf07";
            var errLineColor = "#ff3c07";
            //初始化美洽
            var showBack = false; //是否显示取消按钮
            app.listen("showBackButton", function () {
                showBack = true;
            });
            app.listen("hideBackButton", function () {
                showBack = false;
            });
            if (accountSet.openHandPassLine == true) {
                lineColor = "#ffcf07";
                errLineColor = "#ff3c07";
            } else {
                lineColor = "rgba(255,255,255,0)";
                errLineColor = "rgba(255,255,255,0)";
            }
            if (accountSet.openHandPassword == true) {
                api.openWin({
                    name: "checkhand",
                    url: app.hd + "extrapage/checkhand.html",
                    slidBackEnabled: false,
                    animation: {
                        type: "none"
                    },
                    pageParam: {
                        lineColor: lineColor,
                        errLineColor: errLineColor,
                    }
                });
            }
            app.listen("openhandLine", function (params) {
                var accountSetNew = app.getAccountSet();
                if (accountSet.openHandPassLine == true) {
                    lineColor = "#ffcf07";
                    errLineColor = "#ff3c07";
                } else {
                    lineColor = "rgba(255,255,255,0)";
                    errLineColor = "rgba(255,255,255,0)";
                }
                if (accountSetNew.openHandPassword == true) {
                    api.openWin({
                        name: "checkhand",
                        url: app.hd + "extrapage/checkhand.html",
                        slidBackEnabled: false,
                        animation: {
                            type: "none"
                        },
                        pageParam: {
                            lineColor: lineColor,
                            errLineColor: errLineColor,
                            showBack: showBack
                        }
                    });
                }
            });
        }
        api.ajax({
            url: app.ajaxUrl + "site/get-open-image",
            method: 'post',
            timeout: 30,
            data: {
                values: {}
            }
        }, function (ret, err) {
            api.removeLaunchView({
                animation: {
                    type: 'fade',
                    duration: 500
                }
            });
            if (ret.code == 200) {
                var imgUri = "";
                if (app.SW >= 1356) {
                    imgUri = ret.data.image_1536;
                } else if (app.SW >= 1125) {
                    imgUri = ret.data.image_1125;
                } else {
                    imgUri = ret.data.image_1080;
                }
                $("#dialogIndex").css({
                    width: app.W,
                    height: app.H
                });
                $("#dialogIndex").css({
                    background: "url(" + imgUri + ") no-repeat center",
                    backgroundSize: "100% 100%"
                });
                var accountSet = app.getAccountSet();
                if (accountSet.openHandPassword == true) {
                    openHandPassWord();
                } else {
                    setTimeout(function (params) {
                        app.trigger("passwordSucessful");
                    }, 3000)
                }
            } else {
                var accountSet = app.getAccountSet();
                if (accountSet.openHandPassword == true) {
                    openHandPassWord();
                } else {
                    app.trigger("passwordSucessful");
                }
            }
            if (err) {
                setTimeout(function (params) {
                    app.trigger("passwordSucessful");
                }, 3000)
                return
            }
        });
        var arr = ["passwordSucessful", "closeWinDow"];
        app.listen(arr, function () {
            setTimeout(function (params) {
                openNavTabWin();
            }, 1000)
        });
        var isOpreaHandLine = false;
        app.listen("selectPic", function (params) {
            isOpreaHandLine = true;
        });
        app.listen("selectCompelete", function (params) {
            isOpreaHandLine = true;
            setTimeout(function (params) {
                isOpreaHandLine = false;
            }, 5000)
        })
        // android和ios监听app进入前台
        app.resume(function () {
            if (!isOpreaHandLine) {
                openHandPassWord()
            }
        });
    };
</script>

</html>